
{{include_file name='public/header' title='添加请求参数'}}
<style>
    body {
        background-color: #ffffff;
    }

</style>
</head>

<body>

<div class="container">
    <!-- /.row -->
    <div class="row">
        <form id="js_addRequestFieldForm" role="form" action="{{url('field/add')}}" method="post">
            <input type="hidden" class="form-control" name="field[id]" value="{{$field.id}}">
            <input type="hidden" class="form-control" name="field[parent_id]" value="0">
            <input type="hidden" class="form-control" name="field[api_id]" value="{{$field.api_id}}">
            <input type="hidden" class="form-control" name="field[method]" value="1">

            <div class="form-group">
                <label>参数别名</label>
                <input class="form-control ime-disabled" name="field[name]" value="{{$field.name}}" placeholder="必填，只能是数字和字母组合，且首位不能是数字" datatype="/[a-z|A-Z|0-9|\-|_|\.]$/" nullmsg="请输入接口名称">
            </div>

            <div class="form-group">
                <label>参数含义</label>
                <input class="form-control" name="field[title]" value="{{$field.title}}" placeholder="必填" datatype="*" nullmsg="请输入接口名称">
            </div>

            <div class="form-group">
                <label>参数类型</label>
                <select class="form-control" name="field[type]">
                    {{foreach \app\field::get_type_list() as $k => $type}}
                    <option value="{{$k}}" {{if $field.type == $k}}selected{{/if}}>{{$type}}</option>
                    {{/foreach}}
                </select>
            </div>

            <div class="form-group">
                <label class="control-label">是否必传</label>
                <div class="form-group">
                    <label class="radio-inline">
                        <input type="radio" name="field[is_required]" value="1" checked> 是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="field[is_required]" value="0"> 否
                    </label>

                </div>
            </div>

            <div class="form-group">
                <label>默认值</label>
                <input class="form-control" name="field[default_value]" value="{{$field.default_value}}" placeholder="">
            </div>

            <div class="form-group">
                <label>备注说明</label>
                <textarea class="form-control" name="field[intro]" rows="2" placeholder="非必填">{{$field.intro}}</textarea>
            </div>

            <input type="hidden" id="js_submit" value="提交">

        </form>
        <!-- /.col-lg-12 -->
    </div>
    <!-- /.row -->
</div>
<!-- /#wrapper -->

<script>

    $(function(){

        //验证表单
        var requestFieldModal = $(window.parent.document).find('#js_addRequestFieldModal');
        $("#js_addRequestFieldForm").validateForm({
            submitBtn: '#js_submit',
            before:function () {
                // iframe父级提交按钮禁用
                requestFieldModal.find(".js_submit").attr("disabled", "disabled").text('提交中..');
            },
            success:function () {

                // 重新载入请求参数列表
                var apiId = "{{$field.api_id}}";

                $('#js_addApiForm', parent.document).find(".panel-request").load("{{url('field/load')}}", {'method':1,'api_id':apiId});

                // 关闭父级模态框
                requestFieldModal.find(".js_close").trigger('click');
                requestFieldModal.find(".js_submit").text('提交').removeAttr("disabled");

            },
            error:function () {
                // iframe父级提交按钮激活
                requestFieldModal.find(".js_submit").text('重新提交').removeAttr("disabled");

            }
        });

    });


</script>

{{include_file name='public/footer'}}
